package com.xie.demo.demo;

import org.jetbrains.annotations.NotNull;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * @作者：xie
 * @时间：2023/8/18 9:30
 */
public class PoolTest {
    private final ThreadPoolExecutor threadPoolExecutor;

    {
        final AtomicInteger atomicInteger = new AtomicInteger(0);
        threadPoolExecutor = new ThreadPoolExecutor(8,8,60, TimeUnit.SECONDS,
                new LinkedBlockingQueue<>(1000), new ThreadFactory() {
            @Override
            public Thread newThread(@NotNull Runnable runnable) {
                Thread thread = new Thread(runnable);
                thread.setName("Test"+atomicInteger.getAndIncrement());
                thread.setDaemon(true);
                return null;
            }
        });
    }


    public static void main(String[] args) {
        PoolTest poolTest = new PoolTest();
        poolTest.threadPoolExecutor.execute(() ->{

        });
    }
}
